import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class NoteOrderService {

  // encryptTelId;

  constructor(
    private http: HttpClient
  ) { }

  queryParams = null
  bussinessType = '0'

  formData = null

  // 获取列表
  getCustDetailList(code: string): Observable<any>{
    const url = `/api/gsxmcp/ot/ms/v1.0/mesCust/${code}`;
    return this.http.get(url);
  }

  getCustDetails(): Observable<any>{
    const url = '/api/gsxmcp/ot/ms/v1.0/mesType';
    return this.http.get(url);
  }

  cancelMesCust(id: string): Observable<any>{
    let url = `/api/gsxmcp/ot/ms/v1.0/mesCust/cancle/${id}`;
    return this.http.post(url, null);
  }

  addCustDetails(params: any): Observable<any>{
    const url = '/api/gsxmcp/ot/ms/v1.0/mesCust';
    return this.http.post(url, params);
  }

  // 现改为post方式提交
  getMesCustDetail(code: string, phone: string): Observable<any>{
    // const data = new FormData();
    // data.append("code", code);
    // data.append("phone",phone);
    let data = {
      code, phone
    }
    // let url = `/api/gsxmcp/ot/ms/v1.0/mesCust/detail/${code}/${phone}`;
    let url = `/api/gsxmcp/ot/ms/v1.0/mesCust/detail`;
    return this.http.post(url,data);
  }

  // 获取提交记录
  getMesList(pageNumber: number, pageSize: number): Observable<any>{
    const url = `/api/gsxmcp/ot/ms/v1.0/mesCust/list?pageNumber=${pageNumber}&pageSize=${pageSize}`
    return this.http.get(url)
  }
}

export type NoteOrderDetailData = {
  custUId: string,
  custName: string,
  custTel: string,
  mesTypeName: string,
  encryptTelId: string
}
